package com.example.cloud.controller.common;

import com.example.cloud.model.dto.QueryModel;
import com.example.cloud.model.dto.Result;
import com.example.cloud.service.common.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by wangtao on 2018/4/24.
 */
@Component
public class BaseController {
    @Autowired
    private CommonService commonService;

    /**
     * 单表查询
     * @param queryModel
     * @param clazz
     * @return
     */
    public Result singleQuery(QueryModel queryModel, Class clazz){
        return commonService.query(queryModel, clazz);
    }

    /**
     * 多表查询，基于sql
     * @param queryModel
     * @param sql
     * @param clazz
     * @return
     */
    public Result multiQuery(QueryModel queryModel, StringBuilder sql, Class clazz){
        return commonService.queryBySql(queryModel, sql, clazz);
    }
}
